package com.yuyang.wifi.adapter;

import android.content.Context;
import android.net.wifi.ScanResult;
import android.widget.TextView;

import com.yuyang.wifi.R;
import com.yuyang.wifi.views.recyclerview.base.BaseQuickAdapter;
import com.yuyang.wifi.views.recyclerview.base.BaseViewHolder;

import java.util.List;


public class WifiListAdapter extends BaseQuickAdapter<ScanResult> {

    private String mConnectionWifiName;
    private Context mContext;
    private List<ScanResult> data;

    public WifiListAdapter(Context context, List<ScanResult> data) {
        super(R.layout.item_contract_wifi_list_layout, data);
        this.mContext = context;
        this.data = data;
    }

    public void setConnectionWifi(String connectionWifi) {
        this.mConnectionWifiName = connectionWifi;
    }


    //显示收起时数据
    public void setHideList(List<ScanResult> newList) {
        this.data = newList;
        this.setNewData(data);
    }

    //显示全部数据
    public void setOpenList(List<ScanResult> openList) {
        this.data = openList;
        this.setNewData(data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ScanResult msg) {
        TextView tv_wifi_name = helper.getView(R.id.tv_wifi_name);
        if (msg.SSID != null) {
            helper.setText(R.id.tv_wifi_name, msg.SSID);
            if (msg.SSID.equals(mConnectionWifiName)) {
//                tv_wifi_name.setCompoundDrawablesWithIntrinsicBounds(
//                        mContext.getResources().getDrawable(R.mipmap.ic_wifi_bule), null, null, null);
                helper.setTextColor(R.id.tv_wifi_name, mContext.getResources().getColor(R.color.black_000000));
                helper.setText(R.id.tv_wifi_state, "已连接");
            } else {
//                tv_wifi_name.setCompoundDrawablesWithIntrinsicBounds(
//                        mContext.getResources().getDrawable(R.mipmap.ic_wifi_grey), null, null, null);
                helper.setTextColor(R.id.tv_wifi_name, mContext.getResources().getColor(R.color.text_505352));
                helper.setText(R.id.tv_wifi_state, "免费连接");
            }
        }

    }
}
